package io.renren.modules.app.service.impl;

import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.app.dao.DispatchDao;
import io.renren.modules.app.entity.DispatchEntity;
import io.renren.modules.app.service.DispatchService;
import org.springframework.transaction.annotation.Transactional;


@Service("dispatchService")
public class DispatchServiceImpl extends ServiceImpl<DispatchDao, DispatchEntity> implements DispatchService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DispatchEntity> page = this.page(
                new Query<DispatchEntity>().getPage(params),
                new QueryWrapper<DispatchEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 新增派单记录
     *
     * @param dispatchEntity 派单信息类
     * @return
     */
    @Transactional
    @Override
    public Integer addDispatch(DispatchEntity dispatchEntity) {
        dispatchEntity.setMatchTime(new Date());
        return baseMapper.insert(dispatchEntity);
    }

}